package wekaFM;

import java.util.Enumeration;

import weka.core.Attribute;
import weka.core.Instance;
import weka.core.Instances;

public class InstanceFM extends Instance {

        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        
        private String header = "ren,dur,hic,obc,epa,ssd,sps,avo,log,csp";
        private String ren;
        private String dur;
        private String hic;
        private String obc;
        private String epa;
        private String ssd;
        private String sps;
        private String avo;
        private String log;
        private String csp;

        private String[] attributes;

        public InstanceFM() {
                attributes = new String[10];
                attributes[0] = ren;
                attributes[1] = dur;
                attributes[2] = hic;
                attributes[3] = obc;
                attributes[4] = epa;
                attributes[5] = ssd;
                attributes[6] = sps;
                attributes[7] = avo;
                attributes[8] = log;
                attributes[9] = csp;
        }

        @Override
        public Attribute attribute(int arg0) {
                return new Attribute(attributes[arg0]);
        }

        @Override
        public Attribute attributeSparse(int arg0) {
                return attribute(arg0);
        }

        @Override
        public Attribute classAttribute() {
                return null;
        }

        @Override
        public int classIndex() {
                return 0;
        }

        @Override
        public boolean classIsMissing() {
                return false;
        }

        @Override
        public double classValue() {
                return 0;
        }

        @Override
        public Instances dataset() {
                return null;
        }

        @Override
        public void deleteAttributeAt(int arg0) {
                attributes[arg0] = null;
        }

        @Override
        public Enumeration<Attribute> enumerateAttributes() {
                return null;
        }

        @Override
        public boolean equalHeaders(Instance arg0) {
                if (!InstanceFM.class.equals(arg0.getClass())) {
                        return false;
                } else {
                        return header.equals(((InstanceFM) arg0).getHeader());
                }
        }

        public String equalHeadersMsg(Instance arg0) {
                if (equalHeaders(arg0)) {
                        return "OK";
                } else {
                        return "NON";
                }
        }

        @Override
        public boolean hasMissingValue() {
                return false;
        }

        @Override
        public int index(int arg0) {
                return arg0;
        }

        @Override
        public void insertAttributeAt(int arg0) {
                attributes[arg0] = "new";
        }

        @Override
        public boolean isMissing(int arg0) {
                return false;
        }

        @Override
        public boolean isMissing(Attribute arg0) {
                return false;
        }

        @Override
        public boolean isMissingSparse(int arg0) {
                return false;
        }

        @Override
        public Instance mergeInstance(Instance arg0) {
                InstanceFM newInstance = (InstanceFM) this.copy();
                for (int i = 0; i < newInstance.getAttributes().length; i++) {
                        if (newInstance.getAttributes()[i] == null
                                        || "".equals(attributes[i])) {
                                newInstance.getAttributes()[i] = arg0.attribute(i).toString();
                        }
                }
                return newInstance;
        }

        @Override
        public int numAttributes() {
                return attributes.length;
        }

        @Override
        public int numClasses() {
                return 0;
        }

        @Override
        public int numValues() {
                return 0;
        }

        @Override
        public void replaceMissingValues(double[] arg0) {
        }

        @Override
        public void setClassMissing() {
        }

        @Override
        public void setClassValue(double arg0) {
        }

        @Override
        public void setValue(int arg0, double arg1) {
        }

        @Override
        public void setValueSparse(int arg0, double arg1) {
        }

        @Override
        public double[] toDoubleArray() {
                return null;
        }

        @Override
        public String toStringNoWeight() {
                return toString();
        }

        @Override
        public String toString() {
                String affichage = "";
                affichage += this.header + "\n";
                affichage += this.ren + ", ";
                affichage += this.dur + ", ";
                affichage += this.hic + ", ";
                affichage += this.obc + ", ";
                affichage += this.epa + ", ";
                affichage += this.ssd + ", ";
                affichage += this.sps + ", ";
                affichage += this.avo + ", ";
                affichage += this.log + ", ";
                affichage += this.csp;
                return affichage;
        }

        @Override
        public double value(int arg0) {
                return 0;
        }

        @Override
        public double value(Attribute arg0) {
                return 0;
        }

        @Override
        public double valueSparse(int arg0) {
                return 0;
        }

        @Override
        public Object copy() {
                InstanceFM newInstance = new InstanceFM();
                newInstance.attributes = attributes;
                newInstance.header = header;
                newInstance.ren = ren;
                newInstance.dur = dur;
                newInstance.hic = hic;
                newInstance.obc = obc;
                newInstance.epa = epa;
                newInstance.ssd = ssd;
                newInstance.sps = sps;
                newInstance.avo = avo;
                newInstance.log = log;
                newInstance.csp = csp;
                return newInstance;
        }

        public String getRen() {
                return ren;
        }

        public void setRen(String ren) {
                if (ren.split(" ").length > 1)
                        ren = "'" + ren + "'";
                this.ren = ren;
                this.attributes[0] = ren;
        }

        public String getDur() {
                return dur;
        }

        public void setDur(String dur) {
                if (dur.split(" ").length > 1)
                        dur = "'" + dur + "'";
                this.dur = dur;
                this.attributes[1] = dur;
        }

        public String getHic() {
                return hic;
        }

        public void setHic(String hic) {
                if (hic.split(" ").length > 1)
                        hic = "'" + hic + "'";
                this.hic = hic;
                this.attributes[2] = hic;
        }

        public String getObc() {
                return obc;
        }

        public void setObc(String obc) {
                if (obc.split(" ").length > 1)
                        obc = "'" + obc + "'";
                this.obc = obc;
                this.attributes[3] = obc;
        }

        public String getEpa() {
                return epa;
        }

        public void setEpa(String epa) {
                if (epa.split(" ").length > 1)
                        epa = "'" + epa + "'";
                this.epa = epa;
                this.attributes[4] = epa;
        }

        public String getSsd() {
                return ssd;
        }

        public void setSsd(String ssd) {
                if (ssd.split(" ").length > 1)
                        ssd = "'" + ssd + "'";
                this.ssd = ssd;
                this.attributes[5] = ssd;
        }

        public String getSps() {
                return sps;
        }

        public void setSps(String sps) {
                if (sps.split(" ").length > 1)
                        sps = "'" + sps + "'";
                this.sps = sps;
                this.attributes[6] = sps;
        }

        public String getAvo() {
                return avo;
        }

        public void setAvo(String avo) {
                if (avo.split(" ").length > 1)
                        avo = "'" + avo + "'";
                this.avo = avo;
                this.attributes[7] = avo;
        }

        public String getLog() {
                return log;
        }

        public void setLog(String log) {
                if (log.split(" ").length > 1)
                        log = "'" + log + "'";
                this.log = log;
                this.attributes[8] = log;
        }

        public String getCsp() {
                return csp;
        }

        public void setCsp(String csp) {
                if (csp.split(" ").length > 1)
                        csp = "'" + csp + "'";
                this.csp = csp;
                this.attributes[9] = csp;
        }

        public String[] getAttributes() {
                return attributes;
        }

        public void setHeader(String header) {
                this.header = header;
        }

        public String getHeader() {
                return header;
        }

        public void setAttributes(String[] attributes) {
                this.attributes = attributes;
                this.ren = attributes[0];
                this.dur = attributes[1];
                this.hic = attributes[2];
                this.obc = attributes[3];
                this.epa = attributes[4];
                this.ssd = attributes[5];
                this.sps = attributes[6];
                this.avo = attributes[7];
                this.log = attributes[8];
                this.csp = attributes[9];
        }
}